package com.yxt.admin.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public class AuthToken implements Serializable{

    //令牌信息
    private String accessToken;
    //刷新token(refresh_token)
    private String refreshToken;
    //jwt短令牌
    private String jti;

    private String tokenType;
    private Integer expiresIn;
    private String scope;
    private String customInfo;

    private LocalDateTime expireTime;

    //刷新token
    public AuthToken init() {
        expireTime = LocalDateTime.now().plusSeconds(expiresIn - 3);
        return this;
    }

    @JsonIgnore
    public boolean isExpired() {
        return expireTime.isBefore(LocalDateTime.now());
    }

}